#ifndef INDEXSET_H 
#define INDEXSET_H

#include <iostream>
#include <string>
#include <vector>
#include "Page.h"
#include "Key.h"

#define I_OK 0
#define I_ERROR -1
#define I_NO_EXISTE -2
#define I_UNDERFLOW -3
#define I_OVERFLOW -4
#define I_POSICION_INVALIDA -5

class IndexSet : public Page
{
	protected:
		std::string filename;
		int offset;
		unsigned int level;
		std::vector<Key> keys;
		std::vector<int> hijos;

		unsigned int computeSize();

	public:
		IndexSet();
		IndexSet(const IndexSet& toCopy);
		virtual ~IndexSet();

		void setFilename(std::string name);
		void getFilename(std::string &name);
		void setOffset(int cur);
		int getOffset();
		void setLevel(unsigned int level);
		unsigned int getLevel();

		bool findLastKey(Key* key, unsigned int &pos);
		bool findFirstKey(Key* key, unsigned int &pos);

		int add(Key *key);
		int update(Key *key);
		int remove(Key *key);
		int get(Key *key);
		int get(unsigned int pos, Key *key);

		int addNrr(unsigned int pos, int son);
		int removeNrr(unsigned int pos);
		int getNrr(unsigned int pos, int &son);

		unsigned int getCount();

		void split(Key *newKey, int newNrr, Key* promo, int &nrrPromo);

		void load();
		void save();

		void print();

		const IndexSet &operator=(const IndexSet &toAssign);

};

#endif



